package 回溯;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class q560和为K的子数组 {
    class Solution {
        LinkedList<Integer> path = new LinkedList<>();
        int count = 0;
        int sum = 0;
        public int subarraySum(int[] nums, int k) {
            Arrays.sort(nums);
            backtrack(nums,k,0);
            return count;
        }
        void backtrack(int[] nums, int k,int startIndex){
            if (sum == k) {
                count++;
                return ;
            }
            if(startIndex == nums.length || nums[startIndex]>=k) return;

            for(int i = startIndex; i < nums.length;i++){
                path.push(nums[i]);
                sum+=nums[i];
                backtrack(nums,k,i+1);
                path.pop();
                sum-=nums[i];
            }
        }
    }

    public static void main(String[] args) {

        Solution solution = new q560和为K的子数组().new Solution();
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = scanner.nextInt();
        }
        int res = solution.subarraySum(nums,k);
        System.out.println(res);
    }
}
